package model;

import java.awt.*;

/**
 * Created by wrh on 17-9-16.
 */

public class MyRect{

    private int bottom;
    private int left;
    private int right;
    private int top;

    public MyRect(int left, int top, int right, int bottom) {
        this.bottom = bottom;
        this.left = left;
        this.right = right;
        this.top = top;
    }

    public MyRect(Rectangle rectangle){
        this.bottom = rectangle.y+rectangle.height;
        this.left = rectangle.x;
        this.right = rectangle.x+rectangle.width;
        this.top = rectangle.y;
    }

    public int getBottom() {
        return bottom;
    }

    public int getLeft() {
        return left;
    }

    public int getRight() {
        return right;
    }

    public int getTop() {
        return top;
    }

    /**
     * 判断当前Rect是否是长方形(面积大于0)
     * @return
     */
    public boolean isLegal(){
        if (bottom>0 && left >0 && right>0 && top>0)
            return true;
        else
            return false;
    }

    @Override
    public String toString() {
        return "MyRect{" +
                "bottom=" + bottom +
                ", left=" + left +
                ", right=" + right +
                ", top=" + top +
                '}';
    }
}
